<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>首页</title>
<%@ include file="/pages/inc/taglibs.jsp"%>
</head>
<body>
	<div class="container filter">
		<div class="form-horizontal" id="expenseForm">
			<div class="form-group">
				<label class="control-label col-xs-1" for="usage"> 项目: </label>
				<div class="col-xs-5">
					<select id="project">
						<option value="-1">需要项目负责人分配</option>
						<c-rt:forEach items="${projectSelect}" var="project">
							<option value="${project.id}">${project.projectName}</option>
						</c-rt:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-xs-1" for="usage"> 费用金额: </label>
				<div class="col-xs-5">
					<input type="text" class="form-control" id="expense">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-xs-1" for="date"> 费用科目: </label>
				<div class="col-xs-5">
					<select id="expenseType">
						<c-rt:forEach items="${expenseTypeSelect}" var="expenseType">
							<option value="${expenseType.id}">${expenseType.expenseName}</option>
						</c-rt:forEach>
					</select>
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-xs-1" for="usage"> 摘要</label>
				<div class="col-xs-5">
					<input type="text" class="form-control" id="memo">
				</div>
			</div>
			<div class="form-group">
				<label class="control-label col-xs-1" for="usage"> 凭证编号</label>
				<div class="col-xs-5">
					<input type="text" class="form-control" id="documentNo">
				</div>
			</div>
			<button type="botton" class="btn btn-primary"  onclick="saveExpense()">分配</button>
			<button type="reset" class="btn btn-primary">重置</button>
		</div>
	</div>
	<script type="text/javascript">
		function saveExpense() {
			var json = {};
			json.projectId = $("#project").val();
			json.expense = $("#expense").val();
			json.expenseTypeId = $("#expenseType").val();
			json.memo = $("#memo").val();
			json.documentNo = $("#documentNo").val();
			$.ajax({
				url : "<c:url value='/projectExpense/save' />",
				type : 'POST',
				dataType : 'json',
				data : json,
				success : function(data) {
					$("#expense").val("");
					$("#memo").val("");
					$("#documentNo").val("");
					//$('#expenseForm')[0].reset();
				},
				error : function(data) {
					alert("error");
				}
			});
		}
	</script>
</body>
</html>